package com.wenxixuanwu.fruitstore.config;

import com.wenxixuanwu.fruitstore.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author :小凡凡
 * @version :1.0
 * @Project :fruitstore
 * @Date :2022/5/8
 */
@Configuration
public class LoginInterceptorConfigurer implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        HandlerInterceptor interceptor = new LoginInterceptor();//创建拦截器对象
        registry.addInterceptor(interceptor)
                .addPathPatterns("/cart.html")
                .addPathPatterns("/admin.html")
                .addPathPatterns("/order.html");
    }
}
